/*
 * Lenovo Group
 * Copyright (c) 2015-2016 All Rights Reserved.
 * 
 * Project Name:itsm-gateway
 * Create Time: 2016年3月18日 上午11:07:51
 */
package com.lenovo.lmrp.server.itsmgateway.test.unit;

import org.junit.BeforeClass;
import org.junit.Test;

import com.lenovo.lmrp.server.itsmgateway.ItsmGatewayMain;
import com.lenovo.lmrp.server.itsmgateway.adapter.ms.SyncAttachmentTask;
import com.lenovo.lmrp.server.itsmgateway.repository.TicketRepository;
import com.lenovo.sdc.framework.dao.ADaoFactory;
import com.lenovo.sdc.framework.dao.ICommonDAO;

/**
 * 
 * @author wujin
 * @version v1.0
 */
public class AttachmentSyncTesst {
    private static SyncAttachmentTask syncTask;
    
    @BeforeClass
    public static void init() throws Exception {
        ItsmGatewayMain main = new ItsmGatewayMain();
        main.initializeDAOFactory();
        
        try (ICommonDAO dao = ADaoFactory.getDefault().createDAO("xihe")){
            dao.beginTrans();
            dao.executeSQL("update itsm_ticket_attachment set status = 2", null);
            dao.endTrans();
        }
        catch (Exception exp) {
            exp.printStackTrace();
        }
        
        syncTask = new SyncAttachmentTask("xihe", ADaoFactory.getDefault(), new MockAdapterFactory().createAdapter("xihe"));
    }
    
    @Test
    public void testExecute() throws Exception {
        syncTask.execute();
    }
    
    @Test
    public void testWait() throws Exception {
        Thread.sleep(100000000);
    }
}
